package com.ldzy.webase.exception;

import com.ldzy.webase.utils.Response;
import com.ldzy.webase.utils.ResponseCode;
import lombok.Data;

/**
 * 异常信息类
 */
public class ExceptionResponse extends RuntimeException {
    private Integer code;
    private String msg;

    private ExceptionResponse(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }


    private ExceptionResponse() {
    }

    public static ExceptionResponse build(int code, String msg) {
        return new ExceptionResponse(code, msg);
    }

    public static ExceptionResponse build(ExceptionResponseCode ex) {
        return new ExceptionResponse(ex.getCode(), ex.getDesc());
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }
}
